package light.head.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;


/**
 * 派车记录
 */
@Entity
@Table
public class VehicleAssign implements Serializable{

	private static final long serialVersionUID = 8431305860564603429L;
	private Integer code;
	private Integer vac;					// 申请单编号
	private Integer vc;						// 车辆名称
	private String plate;					// 车牌号
	private String skm;						// 派车时公里数
	private Integer cu;						// 创建人
	private Integer oc;						// 创建机构
	private Date ct = new Date();			// 创建时间
	private Boolean deleted = false;		// 是否删除
	private Boolean revert = false;			// 是否归还
	private Date rt;						// 归还时间
	private Integer dc;						// 司机名称
	private String ekm;						// 归还是公里数
	private String un;						// 使用人
	private String vn;						// 车辆名称
	private String cn;						// 创建人名称
	private String on;						// 创建机构
	private String dn;
	
	private List<VehicleAssign> list;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Integer getVac() {
		return vac;
	}
	@Column
	public Integer getVc() {
		return vc;
	}
	@Column
	public String getPlate() {
		return plate;
	}
	@Column
	public String getSkm() {
		return skm;
	}
	@Column
	public Integer getCu() {
		return cu;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Column
	public Boolean getRevert() {
		return revert;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column
	public Date getRt() {
		return rt;
	}
	@Column
	public String getEkm() {
		return ekm;
	}
	@Column
	public String getUn() {
		return un;
	}
	@Column
	public Integer getDc() {
		return dc;
	}
	@Formula("(SELECT v.name FROM Vehicle v WHERE v.code = vc)")
	public String getVn() {
		return vn;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = dc)")
	public String getDn() {
		return dn;
	}
	
	
	@Transient
	public List<VehicleAssign> getList() {
		return list;
	}
	
	
	
	
	
	
	
	
	


	
	public void setDn(String dn) {
		this.dn = dn;
	}
	public void setUn(String un) {
		this.un = un;
	}
	public void setList(List<VehicleAssign> list) {
		this.list = list;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setVac(Integer vac) {
		this.vac = vac;
	}
	public void setVc(Integer vc) {
		this.vc = vc;
	}
	public void setPlate(String plate) {
		this.plate = plate;
	}
	public void setSkm(String skm) {
		this.skm = skm;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setRevert(Boolean revert) {
		this.revert = revert;
	}
	public void setRt(Date rt) {
		this.rt = rt;
	}
	public void setEkm(String ekm) {
		this.ekm = ekm;
	}
	public void setVn(String vn) {
		this.vn = vn;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	public void setOn(String on) {
		this.on = on;
	}
	public void setDc(Integer dc) {
		this.dc = dc;
	}
	
	
}
